package com.example.finance_oa.controller;

import com.example.comment_oa.pojos.Identify;
import com.example.comment_oa.pojos.Invoice;
import com.example.comment_oa.pojos_vo.AmountVo;
import com.example.comment_oa.pojos_vo.InvoiceVO;
import com.example.comment_oa.response.AjaxResponse;
import com.example.finance_oa.mapper.IdentifyMapper;
import com.example.finance_oa.mapper.InvoiceTypeMapper;
import com.example.finance_oa.service.AmountService;
import com.example.finance_oa.service.InvoiceService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/financeOa")
public class InvoiceController {
    @Autowired
    InvoiceService invoiceService;
    @Autowired
    InvoiceTypeMapper typeMapper;
    @Autowired
    IdentifyMapper identifyMapper;


    @RequestMapping("invoice/allByempId")
    public AjaxResponse allbyempId(@RequestBody InvoiceVO invoiceVO){


        return AjaxResponse.success(invoiceService.allByempId(invoiceVO));
    }


    //查询所有类别
    @RequestMapping("invoice/allType")
    public AjaxResponse allType(){
        return AjaxResponse.success(typeMapper.allType());
    }



    //查询所有辨伪的发票
    @RequestMapping("invoice/allwbw")
    public AjaxResponse allBywbw(){
        return AjaxResponse.success(invoiceService.allBywbw());
    }


    //发票辨伪
    @RequestMapping("invoice/fpbw")
    public AjaxResponse fpbw(@RequestBody InvoiceVO invoiceVO){
        System.out.println(invoiceVO.getInvoicePhone()+""+invoiceVO.invoiceAuthenticity);
        return AjaxResponse.success(invoiceService.invoiceBybw(invoiceVO));
    }

    //删除发票
    @RequestMapping("invoice/deleteInvoice/{invoicePhone}")
    public AjaxResponse deleteInvoice(@PathVariable("invoicePhone") String invoicePhone){
        return AjaxResponse.success(invoiceService.deleteInvoice(invoicePhone));
    }

    //新增发票
    @RequestMapping("invoice/insertInvoice")
    public AjaxResponse insert(@RequestBody Invoice invoice){

        return AjaxResponse.success(invoiceService.insertInvoice(invoice));
    }

    //根据发票号码查重
    @RequestMapping("invoice/invoicePhone/{invoicePhone}")
    public AjaxResponse cc(@PathVariable("invoicePhone")String invoicePhone){
        return AjaxResponse.success(invoiceService.InvoicePhone(invoicePhone));

    }

    //发票辨伪记
    @RequestMapping("invoice/bwjl")
    public AjaxResponse bwjl(@RequestBody Identify identify){
        return AjaxResponse.success(identifyMapper.selectall(identify));
    }

    //根据员工ID查询未报销的发票
    @RequestMapping("invoice/seclctAllwbx/{empId}")
    public AjaxResponse allwbx(@PathVariable("empId")Integer empId){
        return AjaxResponse.success(invoiceService.selectallwbx(empId));
    }
}
